home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15530 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: mail2news.demon.co.uk!tsys.demon.co.uk
  2. From: Tom Wheeley <tomw@tsys.demon.co.uk>
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: Re: H E L P
  5. Date: Sat, 06 Apr 96 13:05:00 GMT
  6. Organization: City Zen FM
  7. Distribution: world
  8. Message-ID: <828795900snz@tsys.demon.co.uk>
  9. References: <N.040296.013047.18@DynamicPPP-185.HIP.CAM.ORG> <Pine.A32.3.91.960402135001.121719B-100000@green.weeg.uiowa.edu> <4js6jh$ndr@solutions.solon.com> <Pine.A32.3.91.960402163729.88458A-100000@black.weeg.uiowa.edu>
  10. Reply-To: tomw@tsys.demon.co.uk
  11. X-NNTP-Posting-Host: tsys.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.30
  13. X-Sig-By: Tomsystems Quote v1.2.  (c)1996 Tom Wheeley, tomw@tsys.demon.co.uk
  14. X-Mail2News-Path: tsys.demon.co.uk
  15.  
  16. In article <Pine.A32.3.91.960402163729.88458A-100000@black.weeg.uiowa.edu>
  17.            robinson@blue.weeg.uiowa.edu "The Amorphous Mass" writes:
  18.  
  19. > On 2 Apr 1996, Peter Seebach wrote:
  20. > > Obviously, if you're assuming age, you would have no more than about 150 ifs
  21. > > to test, (assuming humans), and if you just want to do it for 45, it's even
  22. > > easier.
  23. >   That's true.  Actually, something like
  24. >   char *smileys[] = { "", ":-)", ":-) :-)", ":-) :-) :-)" /* etc. */ };
  25. >   would greatly speed up the programs performance and clarity -- 
  26. > it would be as simple as:
  27. > #include <stdio.h>
  28. > int main(void)
  29. > {
  30. >     int age;
  31. >     scanf("%d", &age);
  32. >     if (age < 0 || age > 150) printf("Very funny, dogbreath.\n");
  33. >     else printf("You're %d years young!\n\n%s\n", age, smileys[age]);
  34. >     return 0;
  35. > }
  36. >   /Tres elegant/, blazingly fast, and much more /sophistique/ than a lowly 
  37. > while() loop.
  38.  
  39. But of course, the best way to write such a program would be using another
  40. C program.  Would you use a loop for this one?  :-)
  41.  
  42. .splitbung
  43. -- 
  44. * TQ 1.0 * The 'Just So Quotes'.
  45. "I'd rather have a bottle in front of me than a frontal lobotomy"
  46.